package com.ming.reggie.mapper;

import com.ming.reggie.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author ming
 */
public interface UserMapper {
    /**
     * 添加用户
     * @return 影响行数
     * @param user 用户对象
     */
    @Insert("insert into user (id,phone,status) values (null,#{phone},#{status})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    Integer addUser(User user);

    /**
     * 根据手机号查询用户
     * @param phone 手机号
     * @return user对象
     */
    @Select("select * from user where phone = #{phone} ")
    User findByPhone(String phone);

    /**
     * 根据登录的用户id查询用户对象
     * @param id
     * @return
     */
    @Select("select * from user where id = #{id}")
    User findById(Long id);
}
